package giit.computerbase.action;

import giit.computerbase.util.Application;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * User: tum0r
 * Package Name: ${PACKAGE_NAME}
 * Time: 2018-11-28 Wednesday 10:00:46
 */
public class LogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding((String) Application.getConfig().pageConfig.get("encode"));
        response.setCharacterEncoding((String) Application.getConfig().pageConfig.get("encode"));
        request.getSession().setAttribute("login", "");
        request.getSession().setAttribute("user", "");
        request.getSession().setAttribute("manager", false);
        response.sendRedirect("warn.jsp?state=panel-primary&title=" + URLEncoder.encode("退出") + "&context=" + URLEncoder.encode("退出成功，点击返回按钮返回主页面") + "&preview=home.jsp");
    }
}
